package com.theme.passport.controller.app;

import com.theme.common.mvc.view.R;
import com.theme.passport.entity.SysDocumentEntity;
import com.theme.passport.entity.constant.DocumentStatusEnum;
import com.theme.passport.entity.constant.DocumentTypeEnum;
import com.theme.passport.service.SysDocumentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @name: DocumentController <tb>
 * @title: 请输入类描述  <tb>
 * @author: cuixinfu@51play.com <tb>
 * @date: 2021/10/25 14:29:47 <tb>
 */
@RestController
@RequestMapping("app/document")
@Api("相关文档:[关于我们,教程与帮助,隐私政策,服务条款]")
public class DocumentController {
    @Autowired
    private SysDocumentService documentService;

    @GetMapping("/introduction")
    @ApiOperation("系统介绍")
    public R introduction(){
        Map<String, Object> params = new HashMap<>();
        params.put("typeId", DocumentTypeEnum.SYS_NTRODUCTION.getValue() +"");
        params.put("state",  DocumentStatusEnum.YET_PUBLISH.getValue() +"");
        SysDocumentEntity document = documentService.queryDocumentByTypeId(params);
        return R.ok().put("document", document);
    }

    @GetMapping("/aboutUs")
    @ApiOperation("关于我们")
    public R aboutUs(){
        Map<String, Object> params = new HashMap<>();
        params.put("typeId", DocumentTypeEnum.ABOUT_US.getValue() +"");
        params.put("state",  DocumentStatusEnum.YET_PUBLISH.getValue() +"");
        SysDocumentEntity document = documentService.queryDocumentByTypeId(params);
        return R.ok().put("document", document);
    }

    @GetMapping("/course")
    @ApiOperation("系统教程")
    public R course(){
        Map<String, Object> params = new HashMap<>();
        params.put("typeId", DocumentTypeEnum.SYS_TUTORIALS.getValue() +"");
        params.put("state",  DocumentStatusEnum.YET_PUBLISH.getValue() +"");
        SysDocumentEntity document = documentService.queryDocumentByTypeId(params);
        return R.ok().put("document", document);
    }

    @GetMapping("/privacyPolicy")
    @ApiOperation("隐私政策")
    public R privacyPolicy(){
        Map<String, Object> params = new HashMap<>();
        params.put("typeId", DocumentTypeEnum.PRIVACY_POLICY.getValue() +"");
        params.put("state",  DocumentStatusEnum.YET_PUBLISH.getValue() +"");
        SysDocumentEntity document = documentService.queryDocumentByTypeId(params);
        return R.ok().put("document", document);
    }

    @GetMapping("/serviceTerms")
    @ApiOperation("服务条款")
    public R serviceTerms(){
        Map<String, Object> params = new HashMap<>();
        params.put("typeId", DocumentTypeEnum.SERVICE_TERMS.getValue() +"");
        params.put("state",  DocumentStatusEnum.YET_PUBLISH.getValue() +"");
        SysDocumentEntity document = documentService.queryDocumentByTypeId(params);
        return R.ok().put("document", document);
    }

    @GetMapping("/help")
    @ApiOperation("系统帮助")
    public R help(){
        Map<String, Object> params = new HashMap<>();
        params.put("typeId", DocumentTypeEnum.SYS_HELP.getValue() +"");
        params.put("state",  DocumentStatusEnum.YET_PUBLISH.getValue() +"");
        SysDocumentEntity document = documentService.queryDocumentByTypeId(params);
        return R.ok().put("document", document);
    }

    @GetMapping("/news")
    @ApiOperation("最新资讯")
    public R news(){
        Map<String, Object> params = new HashMap<>();
        params.put("typeId", DocumentTypeEnum.LATEST_NEWS.getValue() +"");
        params.put("state",  DocumentStatusEnum.YET_PUBLISH.getValue() +"");
        SysDocumentEntity document = documentService.queryDocumentByTypeId(params);
        return R.ok().put("document", document);
    }

}
